package cn.alm.allinoneboot.service.impl;

import cn.alm.allinoneboot.common.CommonResult;
import cn.alm.allinoneboot.service.JedisService;
import cn.alm.allinoneboot.utils.JedisPoolUtil;
import org.springframework.stereotype.Service;
import redis.clients.jedis.Jedis;

@Service
public class JedisServiceImpl implements JedisService {

    @Override
    public CommonResult set(String key, String value) {
        Jedis jedis = JedisPoolUtil.getJedisPoolInstance().getResource();
        String set = jedis.set(key, value);
        CommonResult cr = new CommonResult();
        cr.ok();
        cr.setData(set);
        return cr;
    }

    @Override
    public CommonResult get(String key) {
        Jedis jedis = JedisPoolUtil.getJedisPoolInstance().getResource();
        String s = jedis.get(key);
        CommonResult cr = new CommonResult();
        cr.ok();
        cr.setData(s);
        return cr;
    }
}
